/**
 *  请求数据服务在此声明，页面请求接口调用此文件里的代码
 */

import { post } from '../index';
import {
	getVersionInput,
	getVersionOutput,
	addNewDataOriginalInput,
	commonOutput,
	getConnectListInput,
	deleteConnectInput,
	addModal,
	joinResourceInput,
	activeModelInput, 
	delFileInput, 
	createFileSourceInput, 
	testConnectionInput, 
	dataPreview,
	removeNodeInput,
	nodeInput,
	dataSetInput,
} from './type';

export const getVersion = ( params: getVersionInput ): Promise<getVersionOutput> => {
	return post( '/common/function1', params );
};

export const addNewDataOriginal = ( params: addNewDataOriginalInput ): Promise<commonOutput> => {
	return post( '/common/createResource', params );
};

export const getConnectList = ( params: getConnectListInput ): Promise<commonOutput> => {
	return post( '/common/getResources', params );
};

export const deleteConnect = ( params: deleteConnectInput ): Promise<commonOutput> => {
	return post( '/common/delResource', params );
};

export const getArrangeList = ( params: getConnectListInput ): Promise<commonOutput> => {
	return post( '/common/getModelPage', params );
};

export const createModel = ( params: addModal ): Promise<commonOutput> => {
	return post( '/common/createModel', params );
};

export const deleteModel = ( params: deleteConnectInput ): Promise<commonOutput> => {
	return post( '/common/delModel', params );
};

export const activeModel = ( params: activeModelInput ): Promise<commonOutput> => {
	return post( '/common/activeModel', params );
};

//文件操作
// export const uploadFile = ( params: uploadFileInput ):Promise<commonOutput> => {
// 	return post( '/common/uploadFile',params );
// };

export const delFile = ( params: delFileInput ):Promise<commonOutput> => {
	return post( '/common/delFileBI',params );
};

//文件源创建/追加/覆盖
export const createFileSource = ( params: createFileSourceInput ):Promise<commonOutput> => {
	return post( '/common/createFileResource',{ ...params,timeout: 60000 } );
};

export const appendFileSource = ( params: createFileSourceInput ):Promise<commonOutput> => {
	return post( '/common/appendFileResource',{ ...params,timeout: 60000 } );
};

export const resetFileResource = ( params: createFileSourceInput ):Promise<commonOutput> => {
	return post( '/common/resetFileResource',{ ...params,timeout: 60000 } );
};

//测试连接
export const testConnectionDB = ( params: testConnectionInput ):Promise<commonOutput> => {
	return post( '/common/testConnection',params );
};

//查询数据源下所有集合
export const getSourceTables = ( params: dataPreview ):Promise<commonOutput> => {
	return post( '/common/getTables',params );
};

export const getSourceTableSchema = ( params: dataPreview ):Promise<commonOutput> => {
	return post( '/common/getTableSchema',params );
};

export const getSourceTableData = ( params: dataPreview ):Promise<commonOutput> => {
	return post( '/common/getTableData',params );
};


export const runResource = ( params: dataPreview ):Promise<commonOutput> => {
	return post( '/common/runResource',params );
};

//**************
//数据整理模块
//***************

export const joinResource = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/joinResource',params );
};

export const removeNode = ( params:removeNodeInput ):Promise<commonOutput> => {
	return post( '/dataArrange/removeResource',params );
};

//数据预览
export const nodePreview = ( params:nodeInput ):Promise<commonOutput> => {
	return post( '/dataArrange/nodePreview' ,params );
};

//组件处理
export const nodeHandle = ( params:nodeInput ):Promise<commonOutput> => {
	return post( '/dataArrange/nodeHandle' ,params );
};

//节点关联
export const nodeJoin = ( params:nodeInput ):Promise<commonOutput> => {
	return post( '/dataArrange/nodeJoin' ,params );
};

//更新  节点关联
export const resetNodeJoin = ( params:nodeInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetNodeJoin' ,params );
};


//组件关联
export const componentJoin = ( params:nodeInput ):Promise<commonOutput> => {
	return post( '/dataArrange/componentConnect' ,params );
};

//取消组件关联

export const componetDisconnect = ( params:nodeInput ):Promise<commonOutput> => {
	return post( '/dataArrange/componentDisconnect' ,params );
};

//移除组件
export const componetRemove = ( params:nodeInput ):Promise<commonOutput> => {
	return post( '/dataArrange/removeResource' ,params );
};



//引入输出组件
export const joinOutResource = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/joinOut',params );
};


//更新  引入输出组件
export const resetJoinOutResource = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetJoinOut',params );
};


//任务暂停
export const rJob = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/rjob',params );
};

//触发执行 model
export const triggerModel = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/triggerModel',params );
};

//聚合
export const groupJoin = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/groupJoin',params );
};

//更新 聚合
export const resetGroupJoin = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetGroupJoin',params );
};


//字段拆分
export const fieldSplitJoin = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/arrangeSplitJoin',params );
};

//字段拆分
export const resetFieldSplitJoin = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetRangeSplitJoin',params );
};


//字段移除
export const fieldRemoveJoin = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/arrangeRemoveJoin',params );
};


//更新 字段移除
export const resetFieldRemoveJoin = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetArrangeRemoveJoin',params );
};

//获取文件夹树
export const getModelTree = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/getModelTree',params );
};

//获取单个节点详情
export const getModelInfo = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/getModel',params );
};

//更新节点图最新内容
export const updateContent = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/updateContent',params );
};

//排空
export const removeNone = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/removeNone',params );
};

//更新排空
export const resetRemoveNone = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetRemoveNone',params );
};


//排空数据预览
export const removeNonePreview = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/removeNonePreview',params );
};

//组合字段
export const combinField = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/combinField',params );
};

//更新组合字段
export const resetCombinField = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetCombinField',params );
};

//字段重命名
export const renameField = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/renameField',params );
};

//更新字段重命名
export const resetRenameField = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetRenameField',params );
};

//分组字段数据
export const groupFieldData = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/groupFieldData',params );
};

//分组字段数据
export const groupField = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/groupField',params );
};

//更新分组字段数据
export const resetGroupField = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetGroupField',params );
};


//字段大小写转换
export const caseConversion = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/caseConversion',params );
};


//更新 字段大小写转换
export const resetCaseConversion = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetCaseConversion',params );
};


//去字段空格
export const clearEmpty = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/clearEmpty',params );
};

//去字段空格
export const resetClearEmpty = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetClearEmpty',params );
};

//数据源组件同步状态实时查看
export const realTimeView = ( params:nodeInput ):Promise<commonOutput> => {
	return post( '/dataArrange/realTimeView',params );
};


//替换内容
export const replaceField = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/replaceField',params );
};

//替换内容
export const resetReplaceField = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetReplaceField',params );
};


//查询任务列表
export const taskList = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/taskList',params );
};

//修改数据源组件
export const resourceUpdate = ( params:joinResourceInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resourceUpdate',params );
};

//获取数据集文件夹
export const dataSetGetFiles = ( params:dataSetInput ):Promise<commonOutput> => {
	return post( '/dataArrange/dataSetGetFiles',params );
};

//创建数据集文件夹
export const dataSetCreateFolder = ( params:dataSetInput ):Promise<commonOutput> => {
	return post( '/dataArrange/dataSetCreateFolder',params );
};

//数据集文件夹重命名 
export const dataSetRenameFolder = ( params:dataSetInput ):Promise<commonOutput> => {
	return post( '/dataArrange/dataSetRenameFolder',params );
};

//基于文件夹户获取数据集列表
export const getDataSetPage = ( params:dataSetInput ):Promise<commonOutput> => {
	return post( '/dataArrange/getDataSetPage',params );
};

//创建数据集
export const dataSetCreate = ( params:dataSetInput ):Promise<commonOutput> => {
	return post( '/dataArrange/dataSetCreate',params );
};

//数据集的表重命名
export const dataSetReName = ( params:dataSetInput ):Promise<commonOutput> => {
	return post( '/dataArrange/dataSetReName',params );
};

//删除数据集
export const dataSetDelete = ( id:string ):Promise<commonOutput> => {
	return post( '/dataArrange/dataSetDelete', { id } );
};

//数据集结果预览（分页）
export const getDataSetInfoPage = ( params:any ):Promise<commonOutput> => {
	return post( '/dataArrange/getDataSetInfoPage',params );
};

//计算字段
export const  calculateField = ( params:dataSetInput ):Promise<commonOutput> => {
	return post( '/dataArrange/calculateField',params );
};

//更新 计算字段
export const  resetCalculateField = ( params:dataSetInput ):Promise<commonOutput> => {
	return post( '/dataArrange/resetCalculateField',params );
};

//计算字段  檢測
export const  checkFormula = ( params:dataSetInput ):Promise<commonOutput> => {
	return post( '/dataArrange/checkFormula',params );
};


//获取操作符列表
export const  getOperators = ( params:dataSetInput ):Promise<commonOutput> => {
	return post( '/dataArrange/getOperators',params );
};

//预览表字段值
export const  fieldDataPreview = ( params:any ):Promise<commonOutput> => {
	return post( '/dataArrange/fieldDataPreview',params );
};

//组件重命名
export const  renameComponent = ( params:any ):Promise<commonOutput> => {
	return post( '/dataArrange/renameComponent',params );
};

//清除执行记录
export const clearRecord = ( params:any ):Promise<commonOutput> => {
	return post( '/dataArrange/clearRecord',params );
};
